#!/usr/bin/python3
import sys

rna_pass = {'a': 'A', 'b': 'B', 'c': 'C', 'd': 'D', 'e': 'E',
            'f': 'F', 'g': 'G', 'h': 'H', 'i': 'I', 'j': 'J', 'k': 'K',
            'l': 'L', 'm': 'M', 'n': 'N', 'o': 'O', 'p': 'P',
            'q': 'Q', 'r': 'R', 's': 'S', 't': 'T', 'u': 'U',
            'v': 'V', 'w': 'W', 'x': 'X', 'y': 'Y', 'z': 'Z'}
try:
    t = int(input())
    if t < 1 or t > 100:
        sys.exit(0)
    ret = ''
    for x in range(t):
        a_str = [int(item) for item in input().split()]
        n = a_str[0]
        m = a_str[1]
        k = a_str[2]
        ret = ''
        min_r = 0
        m_str = []
        for i in range(n):
            m_str += [item for item in input()]
        c = k
        for m1 in range(m * n):
            tem_str = m_str[m1]
            tem = rna_pass.get(tem_str, '')
            if tem != '':
                if c < 0:
                    break
                c = c - 1
                min_tem = abs(m_str.index(tem) - m1)
                if min_tem >= m:
                    h = abs(int(m_str.index(tem) / m) - int(m1 / m))
                    min_tem = abs(min_tem - h * m) + h
                if min_r == 0:
                    min_r = min_tem
                    ret = tem_str
                elif min_r > min_tem:
                    min_r = min_tem
                    ret = tem_str
                elif min_r == min_tem and ret > tem_str:
                    ret = tem_str

        print(ret)

except ValueError:
    pass
except EOFError:
    pass
except MemoryError:
    pass
